//
//  AlarmDisposeCell.m
//  efairy
//
//  Created by 李锋 on 2019/2/26.
//  Copyright © 2019年 East. All rights reserved.
//

#import "AlarmDisposeCell.h"
#import "DeviceListCell.h"

@implementation AlarmDisposeCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        [self initView];
    }
    return self;
}


-(void)initView{
    
//    UIView *topLine = [[UIView alloc]init];//线条
//    topLine.backgroundColor  = ColorFromRGB(0xeff0f4);
    
  
    
    //通道类型和通道号
    _pTypeName = [[UILabel alloc]init];
    _pTypeName.font = [UIFont boldSystemFontOfSize:16.f];//字体加粗
    _pTypeName.textColor = ColorFromRGB(0x333333);
    
    //报警类型
    _alarmType = [[UILabel alloc]init];
    _alarmType.font = [UIFont systemFontOfSize:14.f];
    _alarmType.textColor = ColorFromRGB(0x333333);
    _alarmType.textAlignment = NSTextAlignmentRight;
    //报警值title
    _alarmHighestValueLaebl = [[UILabel alloc]init];
    _alarmHighestValueLaebl.font = [UIFont systemFontOfSize:14.f];
    _alarmHighestValueLaebl.textColor = ColorFromRGB(0x333333);
    _alarmHighestValueLaebl.text = @"报警值/阈值";
    //报警值
    _alarmHighestValue = [[UILabel alloc]init];
    _alarmHighestValue.font = [UIFont systemFontOfSize:14.f];
    _alarmHighestValue.textColor = ColorFromRGB(0x999999);
    _alarmHighestValue.textAlignment = NSTextAlignmentRight;
    
    //报警之间title
    _alarmtTimeLaebl = [[UILabel alloc]init];
    _alarmtTimeLaebl.font = [UIFont systemFontOfSize:14.f];
    _alarmtTimeLaebl.textColor = ColorFromRGB(0x333333);
    _alarmtTimeLaebl.text = @"报警时间";
    //报警之间
    _alarmtTime = [[UILabel alloc]init];
    _alarmtTime.font = [UIFont systemFontOfSize:14.f];
    _alarmtTime.textColor = ColorFromRGB(0x999999);
    _alarmtTime.textAlignment = NSTextAlignmentRight;
    
    
    //处理时间title
    _addTimeLaebl = [[UILabel alloc]init];
    _addTimeLaebl.font = [UIFont systemFontOfSize:14.f];
    _addTimeLaebl.textColor = ColorFromRGB(0x333333);
    _addTimeLaebl.text = @"处理时间";
    //处理时间
    _addTime = [[UILabel alloc]init];
    _addTime.font = [UIFont systemFontOfSize:14.f];
    _addTime.textColor = ColorFromRGB(0x999999);
    _addTime.textAlignment = NSTextAlignmentRight;
    
    //处理人名称title
    _disposeUserLabel = [[UILabel alloc]init];
    _disposeUserLabel.font = [UIFont systemFontOfSize:14.f];
    _disposeUserLabel.textColor = ColorFromRGB(0x333333);
    _disposeUserLabel.text = @"处理人名称";
    //处理人名称
    _disposeUser = [[UILabel alloc]init];
    _disposeUser.font = [UIFont systemFontOfSize:14.f];
    _disposeUser.textColor = ColorFromRGB(0x999999);
    _disposeUser.textAlignment = NSTextAlignmentRight;
    
    UIView *line2 = [[UIView alloc]init];
    UIImage *image = [UIImage imageNamed:@"icon_line_bg"];
    line2.layer.contents = (id) image.CGImage;
    
    //描述
    _remarked = [[UILabel alloc]init];
    _remarked.font = [UIFont systemFontOfSize:14.f];
    _remarked.textColor = ColorFromRGB(0x999999);
    _remarked.text = @"处理时间";
    _remarked.numberOfLines = 0;
    _remarked.lineBreakMode = NSLineBreakByCharWrapping;
    
  
    UIView *line3 = [[UIView alloc]init];
    line3.backgroundColor = [UIColor whiteColor];
    
    
   
    [self.contentView sd_addSubviews:@[_pTypeName,_alarmType,_alarmHighestValueLaebl,_alarmHighestValue,
                                       _alarmtTimeLaebl,_alarmtTime,_addTimeLaebl,_addTime,
                                       _disposeUserLabel,_disposeUser,line2,_remarked,line3]];
//    topLine.sd_layout.widthIs(SCREEN_WIDTH).heightIs(8)
//    .topSpaceToView(self.contentView, 0);
    
    _pTypeName.sd_layout.heightIs(16)
    .leftSpaceToView(self.contentView, 12)
    .rightSpaceToView(self.contentView, 84)
    .topSpaceToView(self.contentView,12);
    
    _alarmType.sd_layout.widthIs(84).heightIs(14)
    .rightSpaceToView(self.contentView, 24)
    .topSpaceToView(self.contentView,12);
    
    
    _alarmHighestValueLaebl.sd_layout.heightIs(14)
    .leftSpaceToView(self.contentView, 12)
    .rightSpaceToView(self.contentView, 144)
    .topSpaceToView(_pTypeName,12);
    
    _alarmHighestValue.sd_layout.widthIs(131).heightIs(14)
    .rightSpaceToView(self.contentView, 24)
    .topSpaceToView(_pTypeName,14);
    
    _alarmtTimeLaebl.sd_layout.heightIs(14)
    .leftSpaceToView(self.contentView, 12)
    .rightSpaceToView(self.contentView, 159)
    .topSpaceToView(_alarmHighestValueLaebl,12);
    
    _alarmtTime.sd_layout.widthIs(159).heightIs(14)
    .rightSpaceToView(self.contentView, 24)
    .topSpaceToView(_alarmHighestValueLaebl,12);
    
    _addTimeLaebl.sd_layout.heightIs(14)
    .leftSpaceToView(self.contentView, 12)
    .rightSpaceToView(self.contentView, 159)
    .topSpaceToView(_alarmtTimeLaebl,12);
    
    _addTime.sd_layout.widthIs(159).heightIs(14)
    .rightSpaceToView(self.contentView, 24)
    .topSpaceToView(_alarmtTimeLaebl,12);
    
    
    _disposeUserLabel.sd_layout.heightIs(14)
    .leftSpaceToView(self.contentView, 12)
    .rightSpaceToView(self.contentView, 159)
    .topSpaceToView(_addTimeLaebl,12);
    
    _disposeUser.sd_layout.widthIs(159).heightIs(14)
    .rightSpaceToView(self.contentView, 24)
    .topSpaceToView(_addTimeLaebl,12);
    
    line2.sd_layout.widthIs(SCREEN_WIDTH).heightIs(2)
    .topSpaceToView(_disposeUserLabel, 16);
    
    _remarked.sd_layout.heightIs(14)
    .topSpaceToView(line2,12)
    .leftSpaceToView(self.contentView, 12)
    .rightSpaceToView(self.contentView, 24)
    .autoHeightRatio(0);
    
    
    line3.sd_layout.heightIs(12)
    .topSpaceToView(_remarked, 0);
    
    
    
   
    self.contentView.backgroundColor = [UIColor whiteColor];
    [self setupAutoHeightWithBottomView:line3 bottomMargin:0];
    
}

//定义cell的宽度
- (void)setFrame:(CGRect)frame {
    frame.origin.x += 8;//8 为margin 值
    frame.size.width -= 2 * 8;
    [super setFrame:frame];
}


-(void)setModeDatas:(AlarmDispostListModel *)data{
 
    _pTypeName.text = data.efairydevicealarmstatistics_c_name;//通道名和通道号
    _alarmType.textColor = ColorFromRGB([DeviceListCell getDeviceStateColor:(int)data.efairydevicealarmstatistics_alarm_type]);
    _alarmType.text = [DeviceListCell getDeviceState:((int)data.efairydevicealarmstatistics_alarm_type)];//报警类型
    _alarmHighestValue.text = data.efairydevicealarmstatistics_highest_value;//报警值/阈值
    _alarmtTime.text = data.efairydevicealarmstatistics_start_time;//报警之间
    _addTime.text = data.efairyalarmrecord_add_time;//处理时间
    _disposeUser.text = data.efairyuser_nickname;//处理人员
    _remarked.text = data.efairyalarmrecord_content;//处理内容
    
}


@end
